package com.gz.purchase.library.pojo;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * author wanner1991
 */
public class ShopInfo  extends CustomerSpinnerObject{
    private int shop_id;
    private String shop_name;

    public int getShop_id() {
        return shop_id;
    }

    public void setShop_id(int shop_id) {
        this.shop_id = shop_id;
    }

    public String getShop_name() {
        return shop_name;
    }

    public void setShop_name(String shop_name) {
        this.shop_name = shop_name;
    }

    public static List<ShopInfo> parse(JSONArray jsonArray) throws JSONException {
        if (jsonArray.length() <= 0 || jsonArray == null){
            return null;
        }
        List<ShopInfo> list = new ArrayList<ShopInfo>();
        ShopInfo info ;
        JSONObject object;
        for (int i = 0 ; i < jsonArray.length() ; i++){
            object = jsonArray.getJSONObject(i);
            info = new ShopInfo();
            info.shop_id = object.getInt("shop_id");
            info.shop_name = object.getString("shop_name");
            list.add(info);
        }
        return list;
    }

    @Override
    public String toString() {
        return shop_name;
    }
}
